<?php


namespace Admin\Controller;
use Think\Controller;
class PinglunController extends CommenController {
	public function index(){
		$m = M('usercomment');
		$data = $m->select();
		//dump($data);
		$Model = new \Think\Model();
	/*	$sql = 'select c.createtime ctime,p.name pname,c.content cont,t.name tname from pro_usercomment as c,pro_user as u,pro_text as t,pro_pathclass as p where c.uid = u.id AND t.id = c.tid AND t.tid = p.id';
		$result = $Model ->query($sql);
		$this->assign('data',$result);*/

		$m=M("usercomment");
        $count = $m->count();
        $page = new \Think\Page($count,2);
        $Model = new \Think\Model();
		$sql = "select t.id tid,c.id cid,c.createtime ctime,p.name pname,c.content cont,t.name tname from pro_usercomment as c,pro_user as u,pro_text as t,pro_pathclass as p where c.uid = u.id AND t.id = c.tid AND t.tid = p.id limit $page->firstRow,$page->listRows";
		$result = $Model ->query($sql);
        //dump($result);  
        $this->assign("data",$result);
        $show=$page->show();
        $this->assign("page",$show);
		$this -> display(); 

	}

	public function change(){
        $id = $_GET['id'];
        $q = M('usercomment');
        $ass=$q->where("id = $id")->save(array('content' => '该评论已被删除'));
        if($ass > 0){
            $this->success('修改成功');
        } else{
            $this -> error('修改失败');
        }

    }



}